﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Principal;
using DomainModel;

namespace WebClasses.Security
{
    public class AdminIdentity : IIdentity
    {
        private static AdminIdentity s_anonymous = new AdminIdentity
        {
            UserID = -1,
            UserName = string.Empty,
            IsActivated = true,
            IsAnonymous = true
        };

        internal static AdminIdentity Anonymous
        {
            get
            {
                return s_anonymous;
            }
        }

        public AdminIdentity() { }

        public AdminIdentity(Admin manager)
        {
            this.UserID = manager.ID ?? 0;
            this.UserName = manager.AdminName;
            this.IsActivated = true;
            this.IsAnonymous = false;
        }

        public int UserID { get; private set; }

        public string UserName { get; private set; }

        public bool IsActivated { get; private set; }

        public bool IsAnonymous { get; private set; }

        #region IIdentity Members

        string IIdentity.AuthenticationType
        {
            get
            {
                return "SLY";
            }
        }

        bool IIdentity.IsAuthenticated
        {
            get
            {
                return !this.IsAnonymous;
            }
        }

        string IIdentity.Name
        {
            get
            {
                return this.UserName;
            }
        }

        #endregion
    }
}
